﻿using System;

using Fuse8.ContentManagementFramework.Domain;
using Fuse8.ContentManagementFramework.Domain.Bases;

namespace Fuse8.ContentManagementFramework.Administration.Models
{
    [Serializable]
    public abstract class CmsSiteAwareModel : ISiteAwareEntityObject
    {
        [NonSerialized]
        private SiteAwareCategory _category = SiteAwareCategory.NotDefined;

        #region ISiteAwareEntityObject Members

        public int Id { get; set; }

        public int? SiteGroupId { get; set; }

        public int? SiteId { get; set; }

        public SiteAwareCategory SiteCategory
        {
            get
            {
                if (_category == SiteAwareCategory.NotDefined)
                {
                    _category = this.GetCategory();
                }

                return _category;
            }
            set
            {
                _category = value;
            }
        }

        #endregion

        public bool IsNew
        {
            get
            {
                return Id == 0;
            }
        }
    }
}